home *** CD-ROM | disk | FTP | other *** search
/ Network PC / Network PC.iso / amiga utilities / communication / bbs / termv4.6 / extras / source / gtlayout-source.lha / LTP_BackFillRoutine.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-18  |  4.9 KB  |  194 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14.     // Layer backfill hook support
  15.  
  16. struct LayerMsg
  17. {
  18.     struct Layer        *Layer;
  19.     struct Rectangle     Bounds;
  20. };
  21.  
  22.  
  23. VOID __saveds __asm
  24. LTP_BackfillRoutine(REG(a0) struct Hook *Hook,REG(a1) struct LayerMsg *Bounds,REG(a2) struct RastPort *RPort)
  25. {
  26.     LayoutHandle *Handle = (LayoutHandle *)Hook->h_Data;
  27.  
  28.     if(!Handle->BackfillRastPort.BitMap)
  29.         Handle->BackfillRastPort.BitMap = RPort->BitMap;
  30.  
  31.     BltPattern(&Handle->BackfillRastPort,NULL,Bounds->Bounds.MinX,Bounds->Bounds.MinY,Bounds->Bounds.MaxX,Bounds->Bounds.MaxY,0);
  32. }
  33.  
  34. /*
  35. VOID __saveds __asm
  36. LTP_BackfillRoutine(REG(a0) struct Hook *Hook,REG(a1) struct LayerMsg *Bounds,REG(a2) struct RastPort *RPort)
  37. {
  38.     STATIC UWORD __chip EscherData[216] =
  39.     {
  40.         0xFFF0,0xFFE7,0xF703,0xFF00,0xFFFF,0xFFF9,0xF801,0xFF00,
  41.         0xFFFF,0xFFFE,0xF000,0xFF00,0xFFFF,0xFCFF,0x6000,0x7F00,
  42.         0xFFFF,0xFF3F,0x8020,0x7F00,0xFFFF,0xFFCF,0xC000,0x9F00,
  43.         0xFFFF,0xFFF7,0x8001,0x0700,0xFFFF,0xFFFB,0x8001,0x0100,
  44.         0xFFFF,0xFFFD,0x0001,0x0000,0xFFFF,0xFFFE,0x007F,0xFF00,
  45.         0xFFFF,0xFFFF,0x00FF,0xFF00,0xFFFF,0xFFFF,0x00FF,0xFF00,
  46.         0xFE7F,0xFFFF,0x00FF,0xFF00,0x7F9F,0xFFFF,0x807F,0xFE00,
  47.         0x9FEF,0xFFFF,0x807F,0xFF00,0xE7F7,0xFFFF,0x803F,0x9F00,
  48.         0xFBF8,0x07FF,0xA00F,0xE700,0xFDE0,0x007F,0xB007,0xF900,
  49.         0xFEC0,0x009F,0xB801,0xFE00,0x7F00,0x0067,0xBC00,0xFF00,
  50.         0xBE00,0x0079,0x9E00,0x3F00,0xD800,0x003C,0x6F00,0x1F00,
  51.         0xE000,0x003D,0xF700,0x0F00,0xE006,0x001E,0xF700,0x0700,
  52.         0xC018,0x001E,0xFA00,0x0700,0x8020,0x000F,0x7000,0x0300,
  53.         0x0040,0x600F,0x0000,0x0300,0x0081,0x8000,0x0000,0x0200,
  54.         0xF902,0x0000,0x0000,0x0100,0xFF04,0x0000,0x0000,0x0700,
  55.         0xFF88,0x0C00,0x0000,0x0F00,0xBFD0,0x3000,0x0000,0x1F00,
  56.         0xFFE0,0xC000,0x0000,0x6F00,0xFFE1,0x0000,0x0001,0xF700,
  57.         0xFFE2,0x0000,0x0007,0xF700,0x1FE4,0x0000,0x0000,0x0000,
  58.         0x0FE8,0x0000,0x0000,0x0000,0x0FF0,0x0000,0x0000,0x0000,
  59.         0x0FE0,0x0000,0x0000,0x0000,0x1FE0,0x0000,0x0000,0x0000,
  60.         0x3FE0,0x0000,0x3030,0x0000,0x7FA0,0x0000,0xC0C0,0xC000,
  61.         0xFFA0,0x0001,0x0103,0x0000,0xFF20,0x0002,0x0204,0x0300,
  62.         0xFE20,0x1FFC,0x0408,0x0F00,0xFC20,0x63FF,0x8810,0x1F00,
  63.         0xF821,0x87FF,0xF020,0x3F00,0xF066,0x0FFF,0xF840,0x7F00,
  64.         0xE09C,0x1FFF,0xFC40,0xFF00,0xE104,0x1FFF,0xFE81,0xFF00,
  65.         0xE108,0x3FF9,0xFF81,0xFF00,0xF208,0x3FFE,0x7FC3,0xFF00,
  66.         0xFA10,0x7FFF,0x9FE3,0xFF00,0xFF10,0x7F9F,0xEFF3,0xFF00
  67.     };
  68.  
  69.     struct RastPort __aligned RastPort;
  70.  
  71.     LayoutHandle *Handle = (LayoutHandle *)Hook->h_Data;
  72.  
  73.     LONG    PatternWidth,
  74.             PatternHeight;
  75.  
  76.     LONG    FromMinX,FromMinY,FromMaxX,FromMaxY,
  77.             SaveMinX,SaveMaxX,SaveToMinX,
  78.             ToMinX,ToMinY;
  79.     LONG    Width,Height;
  80.     LONG    Offset;
  81.     LONG    Modulo;
  82.  
  83.     InitRastPort(&RastPort);
  84.     RastPort.BitMap = RPort->BitMap;
  85.     SetABPenDrMd(&RastPort,Handle->DrawInfo->dri_Pens[FILLPEN],Handle->DrawInfo->dri_Pens[BACKGROUNDPEN],JAM2);
  86.  
  87.     Modulo = ((56 + 15) >> 4) * 2;
  88.  
  89.         // Pick up the initial data
  90.  
  91.     PatternWidth    = 56;
  92.     PatternHeight    = 54;
  93.  
  94.     ToMinX            = Bounds->Bounds.MinX;
  95.     ToMinY            = Bounds->Bounds.MinY;
  96.  
  97.     FromMinX        = Bounds->Bounds.MinX;
  98.     FromMinY        = Bounds->Bounds.MinY;
  99.  
  100.     FromMaxX        = Bounds->Bounds.MaxX;
  101.     FromMaxY        = Bounds->Bounds.MaxY;
  102.  
  103.         // NOTEZ-BIEN: the following layer offset adjustments are for
  104.         //             window layer backfill only, for screen layer
  105.         //             backfills the Layer pointer would be invalid.
  106.  
  107.         // Adjust for window left edge
  108.  
  109.     if(Offset = Bounds->Layer->bounds.MinX % PatternWidth)
  110.     {
  111.         FromMinX += Offset;
  112.         FromMaxX += Offset;
  113.     }
  114.  
  115.         // Adjust for window top edge
  116.  
  117.     if(Offset = Bounds->Layer->bounds.MinY % PatternHeight)
  118.     {
  119.         FromMinY += Offset;
  120.         FromMaxY += Offset;
  121.     }
  122.  
  123.         // Save these for later
  124.  
  125.     SaveMinX    = FromMinX;
  126.     SaveMaxX    = FromMaxX;
  127.     SaveToMinX    = ToMinX;
  128.  
  129.     do
  130.     {
  131.         do
  132.         {
  133.                 // Unwrap the left edge
  134.  
  135.             if(PatternWidth <= FromMinX)
  136.             {
  137.                 LONG OldMinX = FromMinX;
  138.  
  139.                 FromMinX %= PatternWidth;
  140.                 FromMaxX -= (OldMinX - FromMinX);
  141.             }
  142.  
  143.                 // Unwrap the top edge
  144.  
  145.             if(PatternHeight <= FromMinY)
  146.             {
  147.                 LONG OldMinY = FromMinY;
  148.  
  149.                 FromMinY %= PatternHeight;
  150.                 FromMaxY -= (OldMinY - FromMinY);
  151.             }
  152.  
  153.                 // Stay within horizontal bounds
  154.  
  155.             if((Width = FromMaxX) >= PatternWidth)
  156.                 Width = PatternWidth - 1;
  157.  
  158.             Width = Width - FromMinX + 1;
  159.  
  160.                 // Stay within vertical bounds
  161.  
  162.             if((Height = FromMaxY) >= PatternHeight)
  163.                 Height = PatternHeight - 1;
  164.  
  165.             Height = Height - FromMinY + 1;
  166.  
  167.                 // Blast in the image
  168.  
  169.             BltTemplate(&((PLANEPTR)EscherData)[FromMinY * Modulo + ((FromMinX & ~0xF) / 8)],FromMinX & 0xF,Modulo,&RastPort,ToMinX,ToMinY,Width,Height);
  170.  
  171.                 // Move up to next column
  172.  
  173.             FromMinX    += Width;
  174.             ToMinX         += Width;
  175.         }
  176.         while(FromMaxX >= FromMinX);
  177.  
  178.             // Return to first column
  179.  
  180.         FromMinX    = SaveMinX;
  181.         FromMaxX    = SaveMaxX;
  182.         ToMinX        = SaveToMinX;
  183.  
  184.             // Move up to next row
  185.  
  186.         Height = PatternHeight - 1 - FromMinY + 1;
  187.  
  188.         FromMinY    += Height;
  189.         ToMinY        += Height;
  190.     }
  191.     while(FromMaxY >= PatternHeight);
  192. }
  193. */
  194.